package jee.boot.module.bpm.validation;

import jee.boot.entity.bpm.BpmConstant;

/**
 * 验证器构造工厂
 */
public class ValidationFactory {
    /**
     * 根据不同的数据校验类型,返回不同的验证器实例
     *
     * @param type
     * @return
     */
    public static DataValidation getInstance(String type) {
        DataValidation dataValidation = null;
        switch (type) {
            case BpmConstant.BPM_COLUMN_DATA_VALIDATION_DATE:
                dataValidation=new DateValidation();
                break;
            case BpmConstant.BPM_COLUMN_DATA_VALIDATION_DATE_TIME:
                dataValidation=new DateTimeValidation();
                break;
            case BpmConstant.BPM_COLUMN_DATA_VALIDATION_EMAIL:
                dataValidation=new EmailValidation();
                break;
            case BpmConstant.BPM_COLUMN_DATA_VALIDATION_NUMBER:
                dataValidation=new NumberValidation();
                break;
            case BpmConstant.BPM_COLUMN_DATA_VALIDATION_NUMBER_LETTER:
                dataValidation=new NumberLetterValidation();
                break;
            case BpmConstant.BPM_COLUMN_DATA_VALIDATION_PHONE:
                dataValidation=new PhoneValidation();
                break;
            case BpmConstant.BPM_COLUMN_DATA_VALIDATION_REQUIRED:
                dataValidation=new EmptyValidation();
                break;
        }
        return dataValidation;
    }
}
